﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClanAPI;

namespace ConsoleApplication1
{
    class Program
    {
        static Int32 Count = 0;
        static TankTotals total = new TankTotals();
        static void Main(string[] args)
        {
            Clan tmp = new Clan(4, "168");
            tmp.PlayerCountChange += new Clan.PlayerCountHandler(test_PlayerCountChange);
            tmp.PlayerCompleteChange += new Clan.GetCompleteHandler(test_PlayerCompleteChange);
            Console.ReadKey();
        }

        static void test_PlayerCountChange(Object Sender, Clan mClan)
        {
            Count++;
            Console.Clear();
            Console.WriteLine(Count + "/" + mClan.TotalPlayers);
        }

        static void test_PlayerCompleteChange(Object Sender, Boolean AllComplete, Clan mClan)
        {
            if (AllComplete)
            {
                Console.Clear();
                Console.WriteLine("Name:" + mClan.Name);
                Console.WriteLine("Tokens:" + mClan.iTokens);
                Console.WriteLine("T10:" + mClan.T10Players);
                Console.WriteLine("T9:" + mClan.T9Players);
                Console.WriteLine("T8 Arty:" + mClan.T8APlayers);
                foreach (Player p in mClan.PlayerList)
                {
                    foreach (Tank t in p.Tanks)
                    {
                        total.UpdateTank(t);
                    }
                }
                Console.WriteLine("----------------------");
                Console.WriteLine("Tank Totals");
                total.TotalTanks.Sort(delegate(TankTotals.sTank cust1, TankTotals.sTank cust2)
                {
                    return Comparer<int>.Default.Compare(cust1.Level, cust2.Level);
                });
                total.TotalTanks.Reverse();
                foreach (TankTotals.sTank s in total.TotalTanks)
                {
                    Console.WriteLine(s.Name + " : " + s.Number);
                }
            }
        }
    }
}
